<#assign contextPath=springMacroRequestContext.getContextPath() />
<#import "/public/frame/main.html" as frame />
<@frame.head "南航明珠商城-专题分类信息">
</@frame.head>
<style>
.itemTable{
background-color:#EDEDED;
}
.itemTable td:nth-child(1){
width:60px;
}
.itemTable td:nth-child(2){
width:250px;
}
.itemContents{
margin-bottom:20px;
}
</style>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 后台管理中心 <span class="c-gray en">&gt;</span> 商品管理 <span class="c-gray en">&gt;</span> 《${templateSpecialTopic.name}》-专题分类信息 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
   <input type="hidden" name="templateSpecialTopicId"  value="${templateSpecialTopic.id}" id="templateSpecialTopicId" />                        
      <div class="cl pd-20 bg-1 bk-gray text-l"  id="itemListDiv">
      <!-- 默认有一个专题分类 -->
      <#if templateSpecialTopic?? && templateSpecialTopic.itemSet??>
      <#list templateSpecialTopic.itemSet as list>
           <div class="itemContents cl pd-10 bg-1 bk-gray">
           <form  method="post"   id="createForm${list_index+1}" name="createForm">
               <input type="hidden" id="itemId${list_index+1}" value="${list.id}" name="templateSpecialTopicItemId"/>
                            <table class="itemTable">
                             <tr>
                               <td>专题分类名称：</td> 
                               <td><input  class="input-text radius" value="${list.name}"  placeholder="请输入专题分类名称" type="text" id="itemName${list_index+1}" name="name" maxlength="50"   onkeyup='this.value=this.value.replace(/^\s+|\s+$/g,"")'/></td>
                               <td><font style="color:red;">*</font>&nbsp;&nbsp;字体颜色：&nbsp;<input style="width:80px;" class="input-text radius jscolor" 
                                         value="${list.topicColor!'FFFFFF'}"  name="topicColor"></td>
                            </tr>
                             <tr>
                               <td>分类说明：</td>
                               <td colspan="2">
                               <textarea style="width:420px;" class="textarea radius" placeholder="请输入分类说明" id="itemDescription${list_index+1}" name="description"
                                         rows="5" cols="90">${list.description}</textarea>
                            </tr> 
                            <tr>
                               <td>分类商品：</td>
                               <td colspan="2"><button class="btn btn-primary radius  size-S" value="${list.description}" type="button" onclick="selectProduct(${list_index+1})">点击选择商品</button><font style="color:red;">*</font></td>
                            </tr>
                             <tr>
                               <td></td>
                               <td colspan="2">
                               <div  class="text-c">
                                   <table id="productTable${list_index+1}"  class="table table-border table-bordered table-bg">
                                       <thead>
                                       <tr class="text-c" >
                                           <th width="100px;">商品编号</th>
                                           <th width="100px;">商品名称</th>
                                           <th width="100px;">商品分类</th>
                                           <th width="100px;">供应商</th>
                                           <th width="100px;">库存</th>
                                           <th width="100px;">商品原价</th>
                                           <th width="100px;">商品价格</th>
                                           <th width="100px;">操作</th>
                                       </tr>
                                       </thead>
                                       <tbody>
                                       <#list list.productSet as product>
                                       <tr class="text-c" id="${list_index + 1}tr${product.id}">
                                        <td>${product.id}</td>
                                        <td>${product.baseInfo.name}</td>
                                        <td>
                                         <#if product.productProperty??>
                                            <#if product.productProperty.prodTypeFour??>
				            		     	 	${product.productProperty.prodTypeFour.name}
                                            <#elseif product.productProperty.prodTypeThree??>
					            	     	 	${product.productProperty.prodTypeThree.name}
                                            <#elseif product.productProperty.prodTypeTwo??>
					            	     	 	${product.productProperty.prodTypeTwo.name}
                                            <#elseif product.productProperty.prodTypeOne??>
					            	     	 	${product.productProperty.prodTypeOne.name}
                                            </#if>
                                          </#if>
                                         </td>
                                         <td>${product.merchant.mercName}</td>
                                         <td>${product.storeInfo.storeNum}</td>
                                         <td>
                                         <#if product.priceInfo.payCostMileage??>
                                         ${product.priceInfo.payCostMileage}公里
                                         <#else>0公里</#if></td>
                                         <td>${product.priceInfo.payOneMileage}公里</td>
                                         <td><a onclick="deleteSelectedProduct(${product.id},${list_index+1})">删除</a></td>
                                       </tr>
                                       </#list>
                                       </tbody>
                                   </table>
                               </div>
                                   <input type="hidden" id="productIds${list_index+1}" value="${productIdsList[list_index]}" name="productIds"/>
                               </td>
                            </tr>
                             <tr>
                               <td><button type="button" class="btn btn-success radius size-S" onclick="addItem(${list_index+1})">保存当前分类</button></td>
                               <td><button type="button" class="btn btn-warning radius size-S" onclick="deleteItem(${list_index+1})">删除当前分类</button></td>
                               <td></td>
                             </tr>
                          </table>     
                     </form>
             </div>
             </#list>
             </#if>
      <!-- 一个隐藏的专题分类,为了添加新专题分类-->
        <div id="itemContent" style="display:none;">
           <div class="itemContents cl pd-10 bg-1 bk-gray">
           <form  method="post"   id="createForm" name="createForm">
               <input type="hidden" id="itemId" name="templateSpecialTopicItemId"/>
                            <table class="itemTable">
                             <tr>
                               <td>专题分类名称：</td> 
                               <td><input  class="input-text radius"  placeholder="请输入专题分类名称" type="text" id="itemName" name="name" maxlength="50"   onkeyup='this.value=this.value.replace(/^\s+|\s+$/g,"")'/></td>
                               <td><font style="color:red;">*</font>&nbsp;&nbsp;字体颜色：&nbsp;<input style="width:80px;" class="input-text radius jscolor" 
                                         value="FFFFFF"  name="topicColor"></td>
                            </tr>
                             <tr>
                               <td>分类说明：</td>
                               <td colspan="2">
                               <textarea style="width:420px;" class="textarea radius" placeholder="请输入分类说明" id="itemDescription" name="description"
                                         rows="5" cols="90"></textarea>
                            </tr> 
                            <tr>
                               <td>分类商品：</td>
                               <td colspan="2"><button class="btn btn-primary radius  size-S" type="button" onclick="selectProduct()">点击选择商品</button><font style="color:red;">*</font></td>
                            </tr>
                             <tr>
                               <td></td>
                               <td colspan="2">
                               <div  class="text-c">
                                   <table id="productTable"  class="table table-border table-bordered table-bg">
                                       <thead>
                                       <tr class="text-c" >
                                           <th width="100px;">商品编号</th>
                                           <th width="100px;">商品名称</th>
                                           <th width="100px;">商品分类</th>
                                           <th width="100px;">供应商</th>
                                           <th width="100px;">库存</th>
                                           <th width="100px;">商品原价</th>
                                           <th width="100px;">商品价格</th>
                                           <th width="100px;">操作</th>
                                       </tr>
                                       </thead>
                                       <tbody>
                                       
                                       </tbody>
                                   </table>
                               </div>
                                   <input type="hidden" id="productIds" value="" name="productIds"/>
                               </td>
                            </tr>
                             <tr>
                               <td><button type="button" class="btn btn-success radius size-S" onclick="addItem()">保存当前分类</button></td>
                               <td><button type="button" class="btn btn-warning radius size-S" onclick="deleteItem()">删除当前分类</button></td>
                               <td></td>
                             </tr>
                          </table>     
                     </form>
                   </div>
            </div>    
        </div>
        <button type="button" class="btn btn-success radius size-S" onclick="createAddItemDiv()">增加专题分类</button>
        <br><br>
    
    <#if type=="edit">
    <div class="cl pd-10 bg-1 bk-gray">
    <table>
      <thead>
      <tr><th colspan="3"><h4>审核结果</h4></th></tr>
      </thead>
      <#if templateSpecialTopic?? &&templateSpecialTopic.logSet??&&(templateSpecialTopic.logSet?size &gt; 0) >
        <#list templateSpecialTopic.logSet as list>
            <tr>
               <td></td>
               <td  colspan="2" >
                  <#if list.result == 1><span class="label label-success radius">审核通过</span>
                  <#elseif list.result == 2><span class="label radius">审核驳回</span>
                  </#if>
                  <br>
                                                        审核说明:${list.remark}
                  <br>
                                                        审核人:${list.user.loginName}
                  <br>
                                                        审核时间:${list.auditDate?string("yyyy-MM-dd HH:mm:ss")}
                  <br>
                  <br>
               </td>
            </tr>
        </#list>
      <#else>
        <tr><td colspan="3">暂无审核记录</td></tr>
      </#if>
   </table>
   </div>
   </#if>
   <input type="button" class="btn btn-primary radius" value="返回列表" onclick="returnList();"/>
   <#if templateSpecialTopic.displayType == null || templateSpecialTopic.displayType == 1>
   <input type="button" class="btn btn-secondary radius" value="预览" onclick="window.open('${clientUrl}/special_topic/preview?templateSpecialTopicId=${templateSpecialTopic.id}')"/>    
   </#if>
</div>
<@frame.end "default">
</@frame.end>
</html>
<script type="text/javascript" src="${contextPath}/resources/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/laypage/laypage.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/jscolor.min.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/special_topic/template_special_topic_item_add_or_update.js"></script>
<script type="text/javascript">
var path="${contextPath}";

<#if templateSpecialTopic?? && templateSpecialTopic.itemSet?? && templateSpecialTopic.itemSet?size &gt; 0>
var index=${templateSpecialTopic.itemSet?size};
<#else>
var index=0;
</#if>
</script>